﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Jungle.Code.BLL;
using Jungle.Code.Utils;
using System.Collections.Generic;
using Jungle.Code.DAL;
using System.Data.SqlClient;
using Jungle.Articles;

	public partial class admin :   BaseAdminModule
	{

        string pocedureName;
        string type;
        int pk;
        string returnUrl;
 

        string cmd = "";
        string cmd2 = "";
		protected void Page_Load(object sender, EventArgs e)
		{
            cmd = Request["cmd"];
            switch (cmd)
            {
                case "mod":
                    newsMenu.ActiveViewIndex = 1;
                    newsMenu.Visible = true;
                    break;
                case "default":
                    newsMenu.ActiveViewIndex = 1;
                    newsMenu.Visible = true;
                    break;
                case "addNews":
                    newsMenu.Visible = true;
                    newsMenu.ActiveViewIndex = 0;
                    break;
                case "Articles":
                    newsMenu.Visible = true;
                    newsMenu.ActiveViewIndex = 1;
                    break;
                case "updateNews":
                    newsMenu.Visible = true;
                    newsMenu.ActiveViewIndex = 2;
                    break;
                case "deleteN":
                    delForm.Visible = true;
                    newsMenu.Visible = true;
                    newsMenu.ActiveViewIndex = 1;
                    break;
            }

            cmd2 = Request["cmd2"];
            switch (cmd2)
            {
                case "deleteN":
                    delForm.Visible = true;
                    newsMenu.Visible = true;
                    newsMenu.ActiveViewIndex = 1;
                    break;
            }

		}
        public override void FillBaseInfo()
        {
            sysName = "Articles";
        }
        public override void Main()
        {
        }

        protected void yesDel(object sender, EventArgs e)
        {
            if (Request["cmd2"] == "deleteN")
            {
                type = "del_news";
                pk = Convert.ToInt32(Request["id_news"]);
            }

            if (Request["cmd"] == "deleteC")
            {
                type = "del_category";
                pk = Convert.ToInt32(Request["id_category"]);
            }

            Article n = new Article();
            n.NewId = pk;
            n.Delete();

            Response.Redirect("~/Admin/Modules.aspx?mod=Articles&cmd=Articles"); 
        }

        protected void noDel(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/Modules.aspx?mod=Articles&cmd=Articles");       
        }
	}
